package com.song.controller.email;

import com.song.entity.EmailEntity;
import com.song.common.Result;
import com.song.service.email.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("${api.version}/email")
public class EmailController {

    @Autowired
    private EmailService emailService;

    @RequestMapping("/emailManage")
    public String showPage() {
        return "email/emailManage";
    }


    /**
     * 发送简单文本
     */
    @RequestMapping("/sendEmail")
    @ResponseBody
    public Result sendEmail(EmailEntity emailEntity) {
        Result result = emailService.sendSimpleEmail(emailEntity);
        return result;
    }

    /**
     * 发送静态资源
     */
    @RequestMapping("/sendResource")
    @ResponseBody
    public Result sendResource(EmailEntity emailEntity) {
        Result result = emailService.sendResource(emailEntity);
        return result;
    }

    /**
     * 发送带有附件邮件
     */
    @RequestMapping("/sendAttachment")
    @ResponseBody
    public Result sendAttachment(EmailEntity emailEntity) {
        Result result = emailService.sendAttachment(emailEntity);
        return result;
    }
}
